home *** CD-ROM | disk | FTP | other *** search
- ===============================================================================
- ░░░░░░░░░░░░░░░▒▒▒▒▒▓▓▓▓ MLIB scarce documentaion ▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
- ===============================================================================
-
- Note: This document looks great in a colorized Borland IDE.
-
- ===============================================================================
- 1. What is it?
-
- MLIB is intended to be a library for game development. It was supposed
- to be similar to YakIcons. It came close, but not enough. It is more abstract
- and unfortunately less optimized.
-
- ===============================================================================
- 2. What does it have?
-
- MLIB has a simple graphics library for the plain VGA mode 0x13. The
- library is written in C++ and some very rare instances of inline assembler
- (I guess that shows that I am not very good at assembler... So if you want
- to draw high-speed primitives, someone will have to do the dirty work. I
- simply assumed that games are written with bitmaps and it is the fastest
- thing I made)
- The rest of the library is written almost completely in C++ and
- has the following classes:
-
- -------------------------------------------------------------------------------
- Note1: one thing, do not delete a pointer that you have just inserted in a
- data storage class like a LList or a HashTable, and do not do that
- with local variables. They would be deleted by the destructor.
- This comment applies to all data storage classes.
-
- Note2: length always denotes the horizontal dimention,
- width always denotes the vertical dimention.
-
- Note3: {} - a member function
- <> - an external function
-
- Note4: Classes are in alphabetical order.
- -------------------------------------------------------------------------------
-
- # AniMob : public MMob
-
- AniMob is a MOB (see MMob) with many AnimLoops that can be cycled
- through. Each AniMob can have any number of AnimLoops. AnimLoops are
- maintained in a linked list.
-
- # AnimLoop : public MObject, public MFileOp
-
- AnimLoop is a linked list of MImages. AnimLoop is designed to
- implement many actions that an object in a game can do. Each AnimLoop may
- represent one action. I think it is easier to understand than a mess of
- images in one place.
-
- # Atom : public MObject, public MFileOp
-
- This is the base data class; it can hold allocated memory. The memory
- is accessed through the pointer {void* mem}. The allocated block is assumed
- to be broken into several subblocks or elements of equal size. Size of each
- element is in {elSize}, number of elements is in {nElem}, and the overall
- size of the allocated block is in {size}. Member functions perform all the
- needed memory operations. The block can be any size under 64K (the limit of
- malloc). This restriction also applies to any classes derived from it.
-
- # Complex : public MObject
-
- A simple complex number class. I know I used it for something...
-
- # DC : public MObject
-
- DC is similar to MS Windows device context. It has information about
- the output address and dimentions, colors, and some other things.
-
- # Display : virtual public MObject
-
- This class describes a place in memory where graphics output is
- being redirected. It has {address}, {length}, and {width}. Usual settings
- are 0xA000, 320, 200 to draw directly to VGA memory.
-
- # HashEntry
-
- All classes derived from this one can be stored in a HashTable. The
- class requires from you a hash key definition routine and the {==} operator.
-
- # HashTable : public Atom
-
- A hash table. Use it in whatever way you like.
-
- # IntPoint
-
- A class that defines integer coordinates for a point. {=}.
-
- # LCList : public LList
-
- Circular doubly linked list. Implemented primarily as a base for
- AnimLoop, but can have other uses.
-
- # LLElem
-
- This is an internal class, which is used as a 'cart' for LList's
- entries.
-
- # LList : public MObject
-
- Doubly linked list. Inserted objects do not contain {next} and
- {prev}. They are pointed to by the 'cart'. Any kind of element can be
- inserted. A 'cart' would be created for it:
- ┌────┐ ┌───┐
- └────┘ -> through InsertAfter -> ══ ══ -> └─╥─┘
- │ ════╩════
- └ Current
-
- # MAplane : public cArray
-
- An offscreen page in memory. {Put},{Get}. Redirect to it using
- <setdpy> and draw. This class could benefit somewhat from an assembler 32 bit
- copy routine, but I did want to make the library to be compatible with 286's.
-
- # MButton : public MLabel
-
- A window class. Executes {UserHandler} if clicked upon with mouse.
-
- # MCMap : public MStGrid
-
- A window class. Sets draw color on left click, fill color on right.
- Displays 256 colors in a box. Based on MStGrid.
-
- # MCheck : public MButton
-
- A window class. Standart checkbox. Calls {UserHandler} on click.
-
- # MEvent : public MObject
-
- This is the event class. Events include key presses, mouse moves, and
- mouse clicks. Obtained by <GetEvent> and created by <CreateEvent>.
-
- # MFileOp
-
- All files derived from this class have {Load} and {Save}. This class
- basically has routines that close and open files and pass the descriptor to
- the derived class.
-
- # MFont : public Atom
-
- A bitmapped font. Draws letters by pixels, which is slow, but it keeps
- the code looking nice and readable.
-
- # MGraph : public MObject
-
- Graphics control structure. Unconditionally defines {font} and
- {palette}. Has a pointer to an Aplane, which can be created by you. Font
- is loaded from "default.fnt" file in current directory. If the file is not
- found, no text will be visible. You can load your own font too.
-
- # MImage : public cArray
-
- A screen image. Stores a block of pixels. {Put},{Get},{Load},{Save}.
- Note: It is RLE compressed when saved to file.
-
- # MKey : public bArray
-
- A keyboard extention. {GetKey},{KeyPress},{KeyFlush}, or access {keys}
- directly ({keys} is a bArray, which is the idea taken from YakIcons).
-
- # MLabel : public MWindow
-
- A window with a label.
-
- # MMob : public MObject, public MFileOp
-
- The Moving OBject class. MOB is an image with a background, that can
- be moved on screen using double-buffering. Mouse is a typical MOB. Use
- {MoveTo} to move and {RescanBackgr} if you draw over it. You can also {Hide}
- and {Show} it.
-
- # MMouse : public MMob
-
- A mouse class. It is usually defined globally and unconditionally if
- you link to MWIN.LIB. I assume that you do not need to create any more mouse
- handlers. Use the default class named <mouse> or if you want more handlers,
- go ahead!
-
- # MObject
-
- The base class for the whole hierarchy. It was created at first to
- use the Borland class library without having to redefine all the pure virtual
- functions. Now I have removed the link to the class library, but if you want
- to enable it, simply include <object.h> in the mobject.h file and the
- conditional compilation will do the rest. This class also defines new
- {new} and {delete}. If you do not want that, undefine USER_NEW_AND_DELETE.
-
- # MPal : public Atom
-
- Palette class. {FadeIn}, {FadeOut}, {SetAll}, {SetRGB}.
-
- # MParent : public MWindow
-
- A window that may have child windows attached. Children are maintained
- in a linked list and are managed automatically. Children create an event upon
- creation to attach themselves to their parent. Call parent's {Realize} to
- attach all the children. The call {Run} and it will go.
-
- # MScGrid : public MScroller
-
- A grid of cells that can be scrolled around. Define {Draw(int,int)} to
- draw one cell with given coordinates.
-
- # MScroller : public MWindow
-
- A simple class that maintains the coordinates of a window in a big
- world. That's it.
-
- # MStGrid : public MWindow
-
- A static grid of elements. Define {Draw(int,int)}.
-
- # MTree : public MObject
-
- This is a multi-leaf tree. Each node is basically a linked list
- element and a linked list in one.
-
- # MWindow : public MTree, public MFileOp
-
- The simplest window. Has size, coordinates, {UserHandler}.
-
- # Queue : public LList
-
- A queue.
-
- # SimpleRect : virtual public MObject
-
- A rectangle with {left},{top},{right}, and {bottom}.
-
- # Stack : public LList
-
- A stack.
-
- # ViewPort : public SimpleRect
-
- SimpleRect with added {length} and {width}.
-
- # bArray : public Atom
-
- Bit array. Access bits with [], which returns BOOL.
-
- # cArray : public Atom
-
- Char array.
-
- # multifile : public MObject
-
- Utility for big data files. To read a file from a multifile use
- {GetOffset (filename)} to get its offset in the big file and read it. See
- the utility mulleman.exe provided to make multifiles.
-
- # wArray : public Atom
-
- Array of WORD values.
-
- -------------------------------------------------------------------------------
-
- If the above reference is not enough, tell me what exactly do you want.
- I am too familiar with the code to be a good judge of what needs to be in the
- documentation, so I wrote what I thought was essential.
-
- ===============================================================================
- 4. How come the demo is so bad?
-
- I can't draw. If you do not believe me, look at pos0.pix. And I hate
- writing specific code. That's probably why I write libraries, not games.
-
- ===============================================================================
- 5. What do you need to run it:
-
- A 80286 processor is preferred, but it may also work under 8086, even
- though I have not tried it because I do not have it. The graphics portion
- needs a VGA screen and card. There may be an incompatibility with some
- very old versions of DOS. Tell me if you find something.
- Current libraries are compiled for an 386. If you have a slower
- machine, recompile them. There is a big chance that they will work.
-
- ===============================================================================
- 6. How to compile a program using it
-
- 1. Include <mio.h>
- 2. If you are using graphics, include <mgr.h>
- 3. If you are using the window system, include <mwindow.h>,
- <mparent.h>, and include files for controls if you have
- used any (all of them can be included with <mcontrol.h>)
- 4. Link with appropriate libraries:
- MMEM.LIB - Always needed
- MIO.LIB - Include for MKey and MMulle
- MTYPES.LIB - Always needed
- MGRAPH.LIB - Graphics library
- MWIN.LIB - Window basics (MWindow, MParent, MEvent, MMouse)
- MCONTROL.LIB - Additional windows
-
- You can recompile the libraries if they do not work with your compiler.
- I have included Borland C++ project and a makefile for each one.
-
- ===============================================================================
- 7. How to use the mouse
-
- The mouse is automatically installed if you link with MWIN.LIB because
- it is assumed that you need mouse for windows, even though a mouse can be used
- without windows. A global class <mouse> is defined, which can be called.
-
- ===============================================================================
- 8. How to use the graphics
-
- The syntax is almost similar to BGI graphics. Initialize with
- <initgraph> with no parameters. This will put you in mode VGA 0x13. To
- restore text mode call closegraph. Look in "mgraph.h" for available
- functions.
- The graphics control structure is global and is called <gr>. It has
- information about current display, i.e. its dimentions, current colors, its
- address. You can draw the primitives or images into any area of memory. Simply
- use the <setdpy> call to set the address and dimentions of the new screen.
- There are useful functions <push_DC> and <pop_DC> which save current
- control structure on stack, so that you do not have to save it yourself.
-
- ===============================================================================
- 9. How to use the windows
-
- The window system is automatically initialized when you link with
- MWIN.LIB but it is not active. Any window you create will attach itself to a
- predefined root window called <root>, which is a global structure. This is
- an event-based system, so it is programmed accordingly. When you have created
- all your windows, call <root.Realize> function to process all the addition
- events at once. Then call <root.Run> and the system will do the rest.
- The above instructions also apply to any parent window that you create.
- Simply replace <root> with your window.
- Windows require a mouse. If you do not have a mouse, get an emulator.
- One is distributed by Microsoft and can be obtained by ftp from
- ftp.microsoft.com in a package called DOS6SUPP.EXE. Or even better, buy
- a mouse! It is one piece of hardware that you WANT to have.
- One more thing, the window system is rather unstable. I have had some
- random reboots for no apparent reason with complex systems like the DRAW
- editor. No, there is never any damage to the system. The cause of the
- unstablity is uncertain.
-
- ===============================================================================
- 10. How to use a Mulle
-
- A Mulle or a multifile is a collection of files in one. To create a
- multifile create a listing of all the files you want to combine. The listing
- file should contain the number of files that you wish to combine. Then use the
- utility MULLEMAN provided in this package (hopefully).
-
- ===============================================================================
- 11. Ok, is it mine?
-
- This library is free. You can have it. If you cannot afford shareware
- because you are a poor college student like myself you will understand what I
- mean. Also, this library is not THAT good to be worth much, it is slow and it
- is in C++. Besides, there are much better libraries that are free, like XLib.
- YakIcons is not free but as I heard, its creator has only earned $23.
- So, you can use MLIB anytime for as long as you want. Only if you
- write something public, include something like <Using MLIB by Mike Sharov>
- somewhere. This is not much to ask, is it?
-
- ===============================================================================
- 12. What to do with bugs?
-
- This library has bugs. I admit it. There is one visible in DRAW,
- where you cannot load an image sometimes (totally random behavior). You can
- save it though. That is a bug somewhere in the windowing system. I did not
- want to give you a defective program, its just that the rest of the library
- works fine and I have almost gave up on that bug, since I have been trying
- to locate it for a very long time. Anyway, if you find any more bugs, or if
- you find where this one is, tell me. My e-mail address is
-
- -------------------------------------------------------------------------------
- msharov@triton.sunlab.cs.runet.edu
- -------------------------------------------------------------------------------
-
- I would really appreciate that.
-
- ===============================================================================